import React from 'react';
import { useHistory, useLocation, useParams, useRouteMatch } from 'react-router-dom/cjs/react-router-dom.min';

const initData = [
  {
    id: 1,
    name: 'aaa'
  },
  {
    id: 2,
    name: 'bbb'
  },
  {
    id: 3,
    name: 'ccc'
  }
]

export default function Student(props) {
  /**
   *  除了通过props获取match、location、history外，也可以使用钩子函数
   */
  const match = useRouteMatch();
  const history = useHistory();
  const location = useLocation();
  const params = useParams();
  console.log(props, match, history, location, params)
  const stu = initData.find(item => item.id === 1);
  return (
    <div>
      {stu.id} --- {stu.name}
    </div>
  )
}
